<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>open</title>

   <script>
      //程序写出 打开链接方式总结

      //1在当前窗口打开, 可后退
      function open1() {

         open("http://tmooc.cn", "_self");
      }

      function open2() {
         location.replace("http://tmooc.cn")
      }

      //3在新窗口打开, 可重复打开
      function open3() {

         window.open("http://tmooc.cn", "_blank");
      }

      //4在新窗口打开, 不可重复打开: target自定义
      function open4() {
         window.open("http://tmooc.cn", "tmooc");
      }
   </script>
</head>

<body>
   <div class="ml16">
      <div>打开链接方式总结:</div>
      <!-- 1在当前窗口打开, 可后退 -->
      <div>1在当前窗口打开, 可后退</div>
      <div class="ml16">
         如: <br>
         <span>方法1:</span>
         <a target="_self" href="http://tmooc.cn">go to tmooc</a> <br>
         <span>方法2:</span>
         <a href="javascript:open1()">go to tmooc(js)</a> <br>
      </div>

      <!-- 2在当前窗口打开, 不可后退 -->
      <div>2在当前窗口打开, 不可后退</div>
      <div class="ml16">
         如: <br>
         <a href="javascript:open2()">go to tmooc(js)</a> <br>
      </div>

      <!-- 3在新窗口打开, 可重复打开 -->
      <div>3在新窗口打开, 可重复打开</div>
      <div class="ml16">
         如: <br>
         <span>方法1:</span>
         <a target="_blank" href="http://tmooc.cn">go to tmooc</a> <br>
         <span>方法2:</span>
         <a href="javascript: open3()">go to tmooc(js)</a> <br>
      </div>

      <!-- 4 -->
      <div>4在新窗口打开, 不可重复打开: target自定义</div>
      <div class="ml16">
         如: <br>
         <span>方法1:</span>
         <a target="tmooc" href="http://tmooc.cn">go to tmooc</a> <br>
         <span>方法2:</span>
         <a href="javascript: open4()">go to tmooc(js)</a> <br>
      </div>
   </div>


</body>

</html>